android layout textview shadow

资料

字体阴影

  1. 硬边缘的阴影效果
  2. 软化阴影
  3. 改变偏移量来有效的改变光源的方向
  4. 浮雕效果
  5. 使用阴影创建光芒特效
  6. 使用阴影创建外发光效果

TextView:shadowDx/Dy/Radius in dip?
If it’s not specified then the unit is always in px.
android:shadowDx, shadowRadius 后面的值是dip还是px还是sp ?
not dp,it’s px,用不同尺寸的手机或模拟器试试便知

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<TextView
android:id="@+id/iv_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_filter_selector"
android:gravity="center"
android:padding="8dp"
android:text="@string/filter"
android:textSize="@dimen/font_small_size"
android:textColor="@color/white"
android:shadowColor="#7F000000"
android:shadowDx="8sp"
android:shadowDy="8sp"
android:shadowRadius="6sp"/>

Error:(166, 39) Dimension types not allowed (at 'shadowDx' with value '8sp').
Error:(167, 39) Dimension types not allowed (at 'shadowDy' with value '8sp').
Error:(168, 43) Dimension types not allowed (at 'shadowRadius' with value '6sp').
Error:(166, 39) Dimension types not allowed (at 'shadowDx' with value '8sp').
Error:(167, 39) Dimension types not allowed (at 'shadowDy' with value '8sp').
Error:(168, 43) Dimension types not allowed (at 'shadowRadius' with value '6sp').

解决方法